# UserInfoButton tap.createUserInfoButton(Object object)

# 功能描述

创建用户信息按钮。使用前请参考 用户信息获取

# 参数

# Object object

属性类型默认值必填说明
typestring按钮的类型。
合法值说明
text可以设置背景色和文本的按钮
image只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高
textstring按钮上的文本,仅当 type 为 text 时有效
imagestring按钮的背景图片,仅当 type 为 image 时有效
styleObject按钮的样式
结构属性类型默认值必填说明
leftnumber左上角横坐标
topnumber左上角纵坐标
widthnumber宽度
heightnumber高度
backgroundColorstring背景颜色
borderColorstring边框颜色
borderWidthnumber边框宽度
borderRadiusnumber边框圆角
colorstring文本的颜色。格式为 6 位 16 进制数。
textAlignstring文本的水平居中方式
合法值说明
left居左
center居中
right居右
fontSizenumber字号
lineHeightnumber文本的行高
withCredentialsbooleantrue是否带上登录态信息。当 withCredentials 为 true 时,要求此前有调用过 tap.login 且登录态尚未过期,此时返回的数据会包含 encryptedData, iv 等敏感信息;当 withCredentials 为 false 时,不要求有登录态,返回的数据不包含 encryptedData, iv 等敏感信息。
langstringen描述用户信息的语言
合法值说明
en英文
zh_CN简体中文
zh_TW繁体中文

# 返回值

# UserInfoButton

# 示例代码

let button = tap.createUserInfoButton({
  type: 'text',
  text: '获取用户信息',
  style: {
    left: 10,
    top: 76,
    width: 200,
    height: 40,
    lineHeight: 40,
    backgroundColor: '#ff0000',
    color: '#ffffff',
    textAlign: 'center',
    fontSize: 16,
    borderRadius: 4
  }
})
button.onTap((res) => {
  console.log(res)
})